// pages/personal_center/personal_center.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    is_coach:0,
    is_venue:0,
    venue_id:'',
    venue_name:'',
    userinfo:[]
  },
  onLoad(){
    let that = this
    wx.request({
      url:app.url+ '/weiapp/api/iscoach',
      data:{
        uid:wx.getStorageSync('uid')
      },
      success:function(res)
      {
        console.log(res)
        that.setData({
          is_coach:res.data.data
        })
        
      }
    }),
      wx.request({
        url: app.url + '/weiapp/api/isvenue',
        data: {
          uid: wx.getStorageSync('uid')
        },
        success: function (res) {
          console.log(res)
          if (res.data.data.status == 1) {
            that.setData({
              is_venue: 1,
              venue_id:res.data.data.id,
              venue_name:res.data.data.name
            })
          }
        }
      }),
      wx.request({
        url: app.url + '/weiapp/api/userinfo',
        data:
        {
          uid:wx.getStorageSync('uid')
        },
        success:function(res)
        {
          console.log(res)
          if(res.data.data.nickname == null)
          {
            wx.navigateTo({
              url: '../login/login',
            })
          }
          that.setData({
            userinfo:res.data.data
          })
        }

      })
  },
  goCalendar(){
    wx.navigateTo({
      url: '../calendar/calendar',
    })
  },
  goMyOrder(){
    wx.navigateTo({
      url: '../my_order/my_order',
    })
  },
  goMyClass() {
    wx.navigateTo({
      url: '../my_class/my_class',
    })
  },
  goMyScore(){
    wx.navigateTo({
      url: '../my_score/my_score',
    })
  },
  goAddCoach(){
    wx.navigateTo({
      url: '../add_coach/add_coach',
    })
  } ,
  goVenueQr(even){
    console.log(even)
    wx.navigateTo({
      url: '../venue_qr/venue_qr?venue_id=' + even.currentTarget.dataset.venue_id,
    })
  },
  goCoachCenter(even){
    wx.navigateTo({
      url: '../coach_center/coach_center',
    })
  },
  goVenueCenter(even) {
    wx.navigateTo({
      url: '../venue_center/venue_center',
    })
  },  
  goSetUserInfo(){
    wx.navigateTo({
      url: '../set_userinfo/set_userinfo',
    })
  },
  goMyTeam(){
    wx.navigateTo({
      url: '../my_team/my_team',
    })
  },
  goMyQr(){
    wx.navigateTo({
      url: '../my_qr/my_qr',
    })    
  },
  goBindMobile() {
    wx.navigateTo({
      url: '../sms/sms',
    })
  },  
  callkf() {
    wx.navigateTo({
      url: '../callkf/callkf',
    })
  },    
  hint(){
    wx.showToast({
      title: '审核中',
    })
  }
})